<?php
namespace app\admin\controller;
use app\admin\model\Order as OrderModel;

//订单管理类
class Order extends Base
{
    public function lst()
    {
        $list = OrderModel::where('or_pay_status',2)->order('or_id DESC')->paginate(10);

        $data = displayJson($list);

        $arr  = json_decode($data,true);

        $newArr = $arr['data'];

        $userIds    = array(); //用户id数组
        $goodsArr   = array(); //商品id数组
        foreach ($newArr as $key => $val) {
            $userIds[]       = $val['or_pay_uid'];
            $goodsArr[]      = $val['or_pay_gid'];
        }

        $user_list     = $this->getUserEmailByIds($userIds);
        $goods_list    = $this->getGoodsByIds($goodsArr);

        foreach ($newArr as $key => &$val) {
            $newArr[$key]['us_status']       = $user_list[$val['or_pay_uid']]['us_status'];
            $newArr[$key]['pay_uid']         = $user_list[$val['or_pay_uid']]['us_email'];
            $newArr[$key]['pay_goods']       = $goods_list[$val['or_pay_gid']];

            unset($newArr[$key]['or_pay_uid']);
            unset($newArr[$key]['or_pay_gid']);
            unset($newArr[$key]['or_pay_status']);
            unset($newArr[$key]['or_create_tme']);
            unset($newArr[$key]['or_notify_code']);
        }

        $arr['data'] = $newArr;

        $info['code'] = '200';
        $info['data'] = $arr;

        echo displayJson($info);die;
    }
}